<?php
/**
 * DMFramework
 * 
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @url http://dmframework.nl
 */

/**
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @package System.Library.Database
 */
class Dmf_Database_Adapter extends Dmf_Database_Adapter_Abstract
{
    /**
     * Executed queries
     * 
     * @var int 
     */
    public static $queries_executed = 0;
    
    /**
     * Get database adapter
     * 
     * @return Dmf_Database_Adapter_Abstract
     * @throws Exception 
     */
    public function getAdapter()
    {
        $class = 'Dmf_Database_Adapter_' . ucfirst( $this->_settings['engine'] );
        
        try 
        {
            $adapter = new $class( $this->_settings );
            
            return $adapter;
        }
        catch( Exception $e )
        {
            throw new Exception( 'Database engine: "' . $this->_settings['engine'] . '" not supported.' );
        }
    }
}